package com.atsmart.app.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.atsmart.app.http.ImageLoader;
import com.atsmart.app.utils.StringUtil;

/**
 * @author hubiao
 *
 */
public class PlaceHolderImageview extends ImageView {

    /**
     * @param context
     * @param attrs
     * @param defStyle
     */
    public PlaceHolderImageview(Context context, AttributeSet attrs,
            int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * @param context
     * @param attrs
     */
    public PlaceHolderImageview(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    /**
     * @param context
     */
    public PlaceHolderImageview(Context context) {
        super(context);
    }

    public void setImageUrl(final String urlString) {
    	setImageUrl(urlString, ImageLoader.IMAGE_KEEP_MEMORY, ImageLoader.SCREEN_ORIGNAL);
    }

    public void setImageUrl(final String urlString, int cacheType) {
    	setImageUrl(urlString, cacheType, ImageLoader.SCREEN_ORIGNAL);
    }

    public void setImageUrl(final String urlString,
            int cacheType, int displayScreenType) {
    	if (StringUtil.isEmptyOrNull(urlString)) {
			return;
		}
    	this.setTag(urlString);
    	ImageLoader.getInstance().displayImage(cacheType, urlString, this, displayScreenType);
    }

    public void setLocalImage(final String urlString) {
    	this.setTag(urlString);
        ImageLoader.getInstance().displayGameImageWithLocal(urlString, this);
    }
}
